<?php
/* @var $this MailConfigController */

$this->breadcrumbs=array(
	'综合控制台'=>array($this->pre_module_url.'/index/index'),
	'网站配置'=>array($this->pre_module_url.'/setting/webconfig'),
	'Email配置'=>array($this->pre_module_url.'/mailConfig/admin'),
);
?>

<?php echo CHtml::beginForm('','post',array('id'=>'mail-config',))?>
	<ul class="form_list form_list2">
		<li class="title"><span class="fs_14 fw_b">Email设置</span></li>
		<li class="c_f"><span class="tit">邮件发送方式：</span>
			<div class="cont f_l type_box" id="tabAds">
				<div class="tab_hd">
					<ul class="c_f">
						<li><input type="radio" name="mail_sent_type" class="radio" value="smtp" <?php if($mailSentType=='smtp') echo 'checked="checked"'?> /><label>采用其他的SMTP服务</label></li>
						<li><input type="radio" name="mail_sent_type" class="radio" value="phpmail" <?php if($mailSentType=='phpmail') echo 'checked="checked"'?> /><label>采用服务器内置的Mail服务(推荐此方式) </label></li>
					</ul>
				</div>
				<div class="tab_cont <?php if($mailSentType=='phpmail') echo 'd_n'?>" >
					<ul class="sub_li c_f">
						<li><span class="tit">SMTP 服务器地址：</span>
							<?php echo CHtml::textField('Congfig[Host]',isset($config['Host'])?$config['Host']:'',array('class'=>'t_ipt w_190','maxlength'=>50))?>
						</li>
						<li><span class="tit">SMTP 服务器端口：</span>
							<?php echo CHtml::textField('Congfig[Port]',isset($config['Port'])?$config['Port']:'25',array('class'=>'t_ipt w_190','maxlength'=>50))?>
						</li>
						<li><span class="tit">SMTP 要求身份验证：</span>
							<?php echo CHtml::radioButtonList('Congfig[SMTPAuth]',isset($config['SMTPAuth'])?$config['SMTPAuth']:'false',array('true'=>'是','false'=>'否'),array('class'=>'radio','labelOptions'=>array('class'=>'mr20')))?>
						</li>
						<li><span class="tit">发信人邮件地址：</span>
							<?php echo CHtml::textField('Congfig[From]',isset($config['From'])?$config['From']:'',array('class'=>'t_ipt w_190','maxlength'=>50))?>
						</li>
						<li><span class="tit">发信人称呼：</span>
							<?php echo CHtml::textField('Congfig[FromName]',isset($config['FromName'])?$config['FromName']:Yii::app()->name,array('class'=>'t_ipt w_190','maxlength'=>32))?>
						</li>
						<li><span class="tit">SMTP 身份验证用户名：</span>
							<?php echo CHtml::textField('Congfig[Username]',isset($config['Username'])?$config['Username']:'',array('class'=>'t_ipt w_190','maxlength'=>32))?>
						</li>
						<li><span class="tit">SMTP 身份验证方式：</span>
							<?php echo CHtml::radioButtonList('Congfig[SMTPSecure]',isset($config['SMTPSecure'])?$config['SMTPSecure']:'',array(''=>'默认','ssl'=>'SSL','tls'=>'TLS'),array('class'=>'radio','labelOptions'=>array('class'=>'mr20')))?>
							<span class="c_999">除非需要，否则不用填写，如Gmail邮箱需要设置为ssl</span>
						</li>
						<li><span class="tit">SMTP 身份验证密码：</span>
							<?php echo CHtml::textField('Congfig[Password]','zeeeda.com',array('class'=>'t_ipt w_190','maxlength'=>32))?>
						</li>
					</ul>
				</div>
			</div>
		</li> 
		<li class="c_f"><span class="tit">测试邮件地址：</span>
			<div class="cont f_l">
				<?php echo CHtml::textField('testmail','',array('class'=>'t_ipt w_250','maxlength'=>50))?>
				<?php echo CHtml::button(Yii::t('adm','Test'),array('class'=>'mem_btn mem_btn13','onclick'=>'testMail()'))?>
			</div>
		</li>
		<li class="c_f"><span class="tit">&nbsp;</span>
			<div class="cont f_l">
				<?php echo CHtml::submitButton(Yii::t('adm','Save Data'),array('class'=>'mem_btn mem_btn20 mr5'))?>
				<?php echo CHtml::resetButton(Yii::t('adm','Reset'),array('class'=>'mem_btn mem_btn07'))?>
			</div>
		</li>
	</ul>
<?php echo CHtml::endForm()?>

<script type="text/javascript">
/*$(function(){
	$('#tabAds').TabADS3();
});*/

$('.tab_hd .radio').bind('click',function(){
	if($(this).val()=='smtp'){
		$(this).parent().parent().parent().next('div').slideDown();
	}else{
		$(this).parent().parent().parent().next('div').slideUp();
	}
})


function testMail(){
	var action = $('#mail-config').attr('action');
	$.ajax({
		   type: "POST",
		   url: "test",
		   data: $('#mail-config').serialize(),
		   success: function(msg){
				if(msg==1){
	    			art.dialog({title: '提示',content: '<?php echo t('邮件发送成功')?>'}).time(1000);
				}else{
					art.dialog({title: '提示',content: msg}).time(1000);
				}
		   }
	});
	$('#mail-config').attr('action',action);
	$('#mail-config').attr('target','');
}
</script>